/**
 * Created by fangshufeng on 2017/9/15.
 */

import React from 'react';

export  default  class  LifeCircle extends React.Component {

    constructor () {
        super();
        console.log('1-----构造函数');
        this.state = {
            name:'test',
        }
    }

    componentWillMount() {
        console.log('2-------componentWillMount');

    }
    render(){
        console.log('3-----render');
        return (
            <h1>{this.state.name}</h1>
        );
    }

    componentDidMount() {
        console.log('4------componentDidMount');
        this.setState({
            name:'这个是更换后的数据',
        })
    }

    shouldComponentUpdate() {
        console.log('state改变的时候会调用');
        return true;

    }

    componentWillUnmount() {
         console.log('componentWillUnmount---组件被删除的时候调用');
    }
}
